﻿using System;

namespace Family.Core.Model
{
    public class OrderItem : EntityWithTypeId<Int32>
    {
        public virtual Decimal Amount { get; set; }

        public virtual Product Product { get; protected set; }

        public virtual Order Order { get; protected set; }

        protected OrderItem() { }

        public OrderItem(Order order, Product product)
        {
            Check.Require(order != null && product != null, new ArgumentNullException("OrderItem .ctor", "parameter is null"));
            Product = product;
            Order = order;
            order.OrderItems.Add(this);
            product.OrderItems.Add(this);
        }
    }
}
